package com.jkoss.wine.config.mvc;

import java.math.BigDecimal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jkoss.common.util.CommonUtil;

import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl;

/**
 * 导出Excel，金额转换
 * 
 * @Author Jason
 * @Version 1.0, 2018年10月28日
 * @See
 * @Since com.jkoss.wine.config.mvc
 * @Description: TODO
 */
public class MoneyExcelHandler extends ExcelDataHandlerDefaultImpl {

	private static final Logger log = LoggerFactory.getLogger(MoneyExcelHandler.class);

	@Override
	public Object exportHandler(Object obj, String name, Object value) {
		Double d = 0.00;
		if (!CommonUtil.isBlank(value)) {
			d = BigDecimal.valueOf(Integer.valueOf(value.toString())).multiply(BigDecimal.valueOf(0.01)).doubleValue();
		}
		return super.exportHandler(obj, name, d);
	}

	@Override
	public Object importHandler(Object obj, String name, Object value) {
		Integer i = 0;
		if (!CommonUtil.isBlank(value)) {
			i = new BigDecimal(value.toString()).multiply(BigDecimal.valueOf(100)).intValue();
		}
		return super.importHandler(obj, name, i);
	}

}